<template>
  <div class="header">
    <div class="headerBox">
      <router-link to="/">
        <img src="https://www.helloimg.com/images/2023/06/10/oszfWv.gif" />
      </router-link>
      <div class="search">
        <input type="text">
        <input type="button">
      </div>
      <button class="userBtn" @click="flag = !flag" :disabled="isToken">三</button>
    </div>
    <div class="userBtnSection" v-if="flag">
      <router-link to="/login">登录</router-link>
      <router-link to="/register">注册</router-link>
      <span>首页</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: false
    }
  },
  computed: {
    isToken() {
      return Boolean(this.$store.state.token)
    }
  }
}
</script>

<style scoped>
.header .headerBox {
  display: flex;
  align-items: center;
  height: 45px;
  background: #d2354c;
  padding: 0 10px;
}

.header img {
  width: 90px;
  height: 27px;
}

.header .search {
  flex: 1;
  background: #fff;
  padding: 0 10px;
  border-radius: 5px;
  margin: 10px;
}

.header .userBtn {
  width: 36px;
  height: 30px;
  border: 1px solid #fff;
  text-align: center;
  line-height: 30px;
  color: #fff;
  background: #d2354c;
}

.header .userBtnSection a,
.header .userBtnSection span {
  display: block;
}


.header .userBtnSection a {
  font-size: 12px;
  height: 30px;
  margin: 10px;
  text-align: center;
  line-height: 30px;
}

.header .userBtnSection a:nth-of-type(1) {
  color: #d13b49;
  background-color: #ffcbd0;
  border-color: #ffb5bc;
}

.header .userBtnSection a:nth-of-type(2) {
  color: #5eb95e;
  background-color: #E4F3E4;
  border-color: #d2e8d2;
}

.header .userBtnSection span {
  margin: 10px;
  color: #d13b49;
  font-size: 18px;
}
</style>